package com.edu.koTA07.adapter;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.edu.koTA07.XmlDataSet.DiskonXmlDataSet;
import com.edu.koTA07.takingOrder.R;

public class DiskonListAdapter extends ArrayAdapter<String> {


	private DiskonXmlDataSet diskonBean;
	private List<String> listDiskon;
	// private ImageLoader imageLoader;

	public DiskonListAdapter(Activity activity, int textViewResourceId,
			List<String> listDiskon, DiskonXmlDataSet diskonBean) {
		super(activity, textViewResourceId, listDiskon);
		inflater = (LayoutInflater) activity
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		// TODO Auto-generated constructor stub
//		activity.getResources();
		this.listDiskon = listDiskon;
		this.diskonBean = diskonBean;
	}

	private static LayoutInflater inflater = null;


	@Override
	public String getItem(int position) {
		return listDiskon.get(position);
	}


	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		String besarDiskon = listDiskon.get(position);
		ViewHolder holder;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.content_diskon, null);
			holder = new ViewHolder();
			holder.textLineBesarDiskon = (TextView) convertView.findViewById(R.id.textLineBesarDiskon);
			holder.textLineJumlahBarang = (TextView) convertView.findViewById(R.id.textLineJumlahBarang);
	       convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.textLineBesarDiskon.setText(besarDiskon);
		holder.textLineJumlahBarang.setText(diskonBean.getJumlahBarang().get(position));
		return convertView;
	}

	class ViewHolder {
		TextView textLineBesarDiskon;
		TextView textLineJumlahBarang;
	}


}
